Laravel Pro Tips
#eager loading #performance #lazy loading
πIf performance is the #1 priority in your project you might want to disable lazy loading completely. Eloquent will throw a huge exception in your face if a relation is not eager-loaded and you try to access it. Just use this snippet:
Martin Joo
#models #lazy loading #n+1
π₯ #Laravel Tip: Protect your database from the dangers of lazy loading by disabling it in your Laravel app. You can also customise how violations are handled, which is perfect for models outside of your control e.g. within packages.
Matt Kingshott
#eloquent #models #lazy loading #n+1
3οΈβ£ You can enable or disable lazy loading for a model using $preventsLazyLoading
Marian Pop πΊπ¦ Laravel Magazine
No articles were found.